"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ProgressMiniLayout = void 0;

var _react = _interopRequireDefault(require("react"));

var _components = require("@tarojs/components");

var _configContext = require("../../../../extends/configContext");

var _classnames = _interopRequireDefault(require("classnames"));

var _injectValue = require("../../../../utils/inject-value");

var _Circle = _interopRequireDefault(require("./Circle"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var ProgressMiniLayout = function ProgressMiniLayout(props) {
  var _classNames;

  var _props$type = props.type,
      type = _props$type === void 0 ? 'line' : _props$type,
      _props$percent = props.percent,
      percent = _props$percent === void 0 ? 0 : _props$percent,
      _props$text = props.text,
      text = _props$text === void 0 ? '' : _props$text,
      _props$theme = props.theme,
      theme = _props$theme === void 0 ? 'default' : _props$theme,
      className = props.className,
      style = props.style,
      _props$isShowText = props.isShowText,
      isShowText = _props$isShowText === void 0 ? true : _props$isShowText;

  var _useConfig = (0, _configContext.useConfig)(),
      clsPrefix = _useConfig.clsPrefix; // Circle


  if (type === 'circle') {
    return /*#__PURE__*/_react.default.createElement(_Circle.default, props);
  }

  return /*#__PURE__*/_react.default.createElement(_components.View, {
    className: (0, _classnames.default)("".concat(clsPrefix, "-progress"), className, (_classNames = {}, _defineProperty(_classNames, "".concat(clsPrefix, "-progress--error"), theme === 'danger'), _defineProperty(_classNames, "".concat(clsPrefix, "-progress--succeed"), theme === 'success'), _classNames)),
    style: style
  }, /*#__PURE__*/_react.default.createElement(_components.View, {
    className: "".concat(clsPrefix, "-progress__value"),
    style: {
      width: "".concat(percent, "%"),
      transition: 'width .2s'
    }
  }, isShowText && /*#__PURE__*/_react.default.createElement("span", {
    className: "".concat(clsPrefix, "-progress__text")
  }, (0, _injectValue.injectValue)(text)(percent))));
};

exports.ProgressMiniLayout = ProgressMiniLayout;